package com.piepesken.mediscale.ui.components.drugs

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

@Composable
fun DrugItemRow(
    title: String,
    effect: String,
    onItemClick: (String) -> Unit = {}
) {
    Column(
        modifier = Modifier
            .clickable(onClick = {
                onItemClick(title)
            })
            .fillMaxWidth()
            .padding(PaddingValues(8.dp, 16.dp)),
        verticalArrangement = Arrangement.Center
    ) {
        Text(
            text = title,
            fontSize = MaterialTheme.typography.titleMedium.fontSize,
            color = MaterialTheme.typography.titleMedium.color,
        )

        if ("" != effect) {
            Text(
                text = effect,
                fontSize = MaterialTheme.typography.labelSmall.fontSize,
                color = MaterialTheme.typography.labelSmall.color,
                modifier = Modifier.padding(top = 4.dp)
            )
        }
    }
}

@Preview(showBackground = true)
@Composable
fun DrugItemRowPreview() {
    DrugItemRow(title = "陈皮", effect = "老干妈", onItemClick = { })
}